.class public Lrexsee/keyboard/RexseeSensorBoard;
.super Ljava/lang/Object;
.source "RexseeSensorBoard.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# static fields
.field public static final INTERFACE_NAME:Ljava/lang/String; = "SensorBoard"


# instance fields
.field private direction:I

.field private downKeycode:I

.field private lastUpdate:J

.field private leftKeycode:I

.field private final mBrowser:Lrexsee/core/browser/Browser;

.field private final mContext:Landroid/content/Context;

.field private mSensor:Landroid/hardware/Sensor;

.field private mSensorListener:Landroid/hardware/SensorEventListener;

.field private mSensorManager:Landroid/hardware/SensorManager;

.field private rightKeycode:I

.field private upKeycode:I


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 3
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    const/4 v0, 0x0

    const/4 v2, -0x1

    .line 42
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 31
    iput-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorManager:Landroid/hardware/SensorManager;

    .line 32
    iput-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorListener:Landroid/hardware/SensorEventListener;

    .line 33
    iput-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensor:Landroid/hardware/Sensor;

    .line 35
    const-wide/16 v0, -0x1

    iput-wide v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->lastUpdate:J

    .line 36
    iput v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->upKeycode:I

    .line 37
    iput v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->downKeycode:I

    .line 38
    iput v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->leftKeycode:I

    .line 39
    iput v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->rightKeycode:I

    .line 40
    iput v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->direction:I

    .line 43
    invoke-virtual {p1}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mContext:Landroid/content/Context;

    .line 44
    iput-object p1, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    .line 45
    return-void
.end method

.method static synthetic access$0(Lrexsee/keyboard/RexseeSensorBoard;)J
    .locals 2

    .prologue
    .line 35
    iget-wide v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->lastUpdate:J

    return-wide v0
.end method

.method static synthetic access$1(Lrexsee/keyboard/RexseeSensorBoard;J)V
    .locals 0

    .prologue
    .line 35
    iput-wide p1, p0, Lrexsee/keyboard/RexseeSensorBoard;->lastUpdate:J

    return-void
.end method

.method static synthetic access$2(Lrexsee/keyboard/RexseeSensorBoard;I)V
    .locals 0

    .prologue
    .line 47
    invoke-direct {p0, p1}, Lrexsee/keyboard/RexseeSensorBoard;->sendKey(I)V

    return-void
.end method

.method private sendKey(I)V
    .locals 2
    .param p1, "newDirection"    # I

    .prologue
    .line 48
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->direction:I

    if-ne p1, v0, :cond_1

    .line 98
    :cond_0
    :goto_0
    return-void

    .line 49
    :cond_1
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->direction:I

    packed-switch v0, :pswitch_data_0

    .line 67
    :cond_2
    :goto_1
    :pswitch_0
    packed-switch p1, :pswitch_data_1

    goto :goto_0

    .line 69
    :pswitch_1
    const/4 v0, -0x1

    iput v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->direction:I

    goto :goto_0

    .line 53
    :pswitch_2
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->upKeycode:I

    if-lez v0, :cond_2

    iget-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->function:Lrexsee/core/browser/RexseeBrowser;

    iget v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->upKeycode:I

    invoke-virtual {v0, v1}, Lrexsee/core/browser/RexseeBrowser;->keyUp(I)V

    goto :goto_1

    .line 56
    :pswitch_3
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->downKeycode:I

    if-lez v0, :cond_2

    iget-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->function:Lrexsee/core/browser/RexseeBrowser;

    iget v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->downKeycode:I

    invoke-virtual {v0, v1}, Lrexsee/core/browser/RexseeBrowser;->keyUp(I)V

    goto :goto_1

    .line 59
    :pswitch_4
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->leftKeycode:I

    if-lez v0, :cond_2

    iget-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->function:Lrexsee/core/browser/RexseeBrowser;

    iget v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->leftKeycode:I

    invoke-virtual {v0, v1}, Lrexsee/core/browser/RexseeBrowser;->keyUp(I)V

    goto :goto_1

    .line 62
    :pswitch_5
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->rightKeycode:I

    if-lez v0, :cond_2

    iget-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->function:Lrexsee/core/browser/RexseeBrowser;

    iget v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->rightKeycode:I

    invoke-virtual {v0, v1}, Lrexsee/core/browser/RexseeBrowser;->keyUp(I)V

    goto :goto_1

    .line 72
    :pswitch_6
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->upKeycode:I

    if-lez v0, :cond_0

    .line 73
    iget-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->function:Lrexsee/core/browser/RexseeBrowser;

    iget v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->upKeycode:I

    invoke-virtual {v0, v1}, Lrexsee/core/browser/RexseeBrowser;->keyDown(I)V

    .line 74
    const/4 v0, 0x0

    iput v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->direction:I

    goto :goto_0

    .line 78
    :pswitch_7
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->downKeycode:I

    if-lez v0, :cond_0

    .line 79
    iget-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->function:Lrexsee/core/browser/RexseeBrowser;

    iget v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->downKeycode:I

    invoke-virtual {v0, v1}, Lrexsee/core/browser/RexseeBrowser;->keyDown(I)V

    .line 80
    const/4 v0, 0x1

    iput v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->direction:I

    goto :goto_0

    .line 84
    :pswitch_8
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->leftKeycode:I

    if-lez v0, :cond_0

    .line 85
    iget-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->function:Lrexsee/core/browser/RexseeBrowser;

    iget v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->leftKeycode:I

    invoke-virtual {v0, v1}, Lrexsee/core/browser/RexseeBrowser;->keyDown(I)V

    .line 86
    const/4 v0, 0x2

    iput v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->direction:I

    goto :goto_0

    .line 90
    :pswitch_9
    iget v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->rightKeycode:I

    if-lez v0, :cond_0

    .line 91
    iget-object v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->function:Lrexsee/core/browser/RexseeBrowser;

    iget v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->rightKeycode:I

    invoke-virtual {v0, v1}, Lrexsee/core/browser/RexseeBrowser;->keyDown(I)V

    .line 92
    const/4 v0, 0x3

    iput v0, p0, Lrexsee/keyboard/RexseeSensorBoard;->direction:I

    goto/16 :goto_0

    .line 49
    nop

    :pswitch_data_0
    .packed-switch -0x1
        :pswitch_0
        :pswitch_2
        :pswitch_3
        :pswitch_4
        :pswitch_5
    .end packed-switch

    .line 67
    :pswitch_data_1
    .packed-switch -0x1
        :pswitch_1
        :pswitch_6
        :pswitch_7
        :pswitch_8
        :pswitch_9
    .end packed-switch
.end method


# virtual methods
.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 21
    return-object p0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 17
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "SensorBoard"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getNewInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 1
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 25
    new-instance v0, Lrexsee/keyboard/RexseeSensorBoard;

    invoke-direct {v0, p1}, Lrexsee/keyboard/RexseeSensorBoard;-><init>(Lrexsee/core/browser/Browser;)V

    return-object v0
.end method

.method public start(IIIII)V
    .locals 9
    .param p1, "zAngle"    # I
    .param p2, "upKeycode"    # I
    .param p3, "downKeycode"    # I
    .param p4, "leftKeycode"    # I
    .param p5, "rightKeycode"    # I

    .prologue
    .line 101
    const-string v1, "fastest"

    const/16 v2, 0x64

    const/16 v3, 0xa

    move-object v0, p0

    move v4, p1

    move v5, p2

    move v6, p3

    move v7, p4

    move v8, p5

    invoke-virtual/range {v0 .. v8}, Lrexsee/keyboard/RexseeSensorBoard;->start(Ljava/lang/String;IIIIIII)V

    .line 102
    return-void
.end method

.method public start(Ljava/lang/String;IIIIIII)V
    .locals 5
    .param p1, "rate"    # Ljava/lang/String;
    .param p2, "cycle"    # I
    .param p3, "accuracy"    # I
    .param p4, "zAngle"    # I
    .param p5, "upKeycode"    # I
    .param p6, "downKeycode"    # I
    .param p7, "leftKeycode"    # I
    .param p8, "rightKeycode"    # I

    .prologue
    .line 104
    iput p5, p0, Lrexsee/keyboard/RexseeSensorBoard;->upKeycode:I

    .line 105
    iput p6, p0, Lrexsee/keyboard/RexseeSensorBoard;->downKeycode:I

    .line 106
    iput p7, p0, Lrexsee/keyboard/RexseeSensorBoard;->leftKeycode:I

    .line 107
    iput p8, p0, Lrexsee/keyboard/RexseeSensorBoard;->rightKeycode:I

    .line 108
    invoke-static {p1}, Lrexsee/sensor/SensorRate;->getInt(Ljava/lang/String;)I

    move-result v1

    .line 110
    .local v1, "mRate":I
    :try_start_0
    iget-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mContext:Landroid/content/Context;

    const-string v3, "sensor"

    invoke-virtual {v2, v3}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/hardware/SensorManager;

    iput-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorManager:Landroid/hardware/SensorManager;

    .line 111
    iget-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorManager:Landroid/hardware/SensorManager;

    const/4 v3, 0x3

    invoke-virtual {v2, v3}, Landroid/hardware/SensorManager;->getDefaultSensor(I)Landroid/hardware/Sensor;

    move-result-object v2

    iput-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensor:Landroid/hardware/Sensor;

    .line 112
    iget-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensor:Landroid/hardware/Sensor;

    if-nez v2, :cond_0

    .line 113
    iget-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/keyboard/RexseeSensorBoard;->getInterfaceName()Ljava/lang/String;

    move-result-object v3

    const-string v4, "Orientation sensor is not found."

    invoke-virtual {v2, v3, v4}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/String;)V

    .line 115
    :cond_0
    new-instance v2, Lrexsee/keyboard/RexseeSensorBoard$1;

    invoke-direct {v2, p0, p2, p4, p3}, Lrexsee/keyboard/RexseeSensorBoard$1;-><init>(Lrexsee/keyboard/RexseeSensorBoard;III)V

    iput-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorListener:Landroid/hardware/SensorEventListener;

    .line 148
    iget-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorManager:Landroid/hardware/SensorManager;

    iget-object v3, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorListener:Landroid/hardware/SensorEventListener;

    iget-object v4, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensor:Landroid/hardware/Sensor;

    invoke-virtual {v2, v3, v4, v1}, Landroid/hardware/SensorManager;->registerListener(Landroid/hardware/SensorEventListener;Landroid/hardware/Sensor;I)Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 152
    :goto_0
    return-void

    .line 149
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 150
    .local v0, "e":Ljava/lang/Exception;
    iget-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3, v0}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    goto :goto_0
.end method

.method public stop()V
    .locals 3

    .prologue
    .line 154
    iget-object v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorManager:Landroid/hardware/SensorManager;

    if-eqz v1, :cond_0

    iget-object v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorListener:Landroid/hardware/SensorEventListener;

    if-nez v1, :cond_1

    .line 163
    :cond_0
    :goto_0
    return-void

    .line 156
    :cond_1
    :try_start_0
    iget-object v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorManager:Landroid/hardware/SensorManager;

    iget-object v2, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorListener:Landroid/hardware/SensorEventListener;

    invoke-virtual {v1, v2}, Landroid/hardware/SensorManager;->unregisterListener(Landroid/hardware/SensorEventListener;)V

    .line 157
    const/4 v1, 0x0

    iput-object v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensor:Landroid/hardware/Sensor;

    .line 158
    const/4 v1, 0x0

    iput-object v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorManager:Landroid/hardware/SensorManager;

    .line 159
    const/4 v1, 0x0

    iput-object v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->mSensorListener:Landroid/hardware/SensorEventListener;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 160
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 161
    .local v0, "e":Ljava/lang/Exception;
    iget-object v1, p0, Lrexsee/keyboard/RexseeSensorBoard;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2, v0}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    goto :goto_0
.end method
